﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Erebos.GameScreenFiles
{
    class InterfaceOverlay
    {
        private Charackter _charackter;

        public InterfaceOverlay(ref Charackter charackter) 
        {
            _charackter = charackter;
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            //Rang-Name
            Texture2D tex = null;
            if (_charackter.Rights.ToString() == "20000") //Moderator
                tex = MainGame.Textures["Rang/Mod"];
            else if (_charackter.Rights.ToString() == "22001") //Bote
                tex = MainGame.Textures["Rang/Bote"];
            else if (_charackter.Rights.ToString() == "22221") //Super-Bote
                tex = MainGame.Textures["Rang/SuperBote"];
            else if (_charackter.Rights.ToString() == "22222") //Admin
                tex = MainGame.Textures["Rang/Admin"];

            if(tex != null)
            {
                Vector2 position = new Vector2(ScreenSizeHelper.SizeWidth / 2 - tex.Width / 4, 0);
                spriteBatch.Draw(tex, new Rectangle((int)position.X, (int)position.Y - 15, tex.Width / 2, tex.Height / 2), Color.White);
            }
            
            //Menu Button
            Vector2 posMenuButton = new Vector2(0, ScreenSizeHelper.SizeHeight - MainGame.Textures["Overlay/MenuButton"].Height);
            spriteBatch.Draw(MainGame.Textures["Overlay/MenuButton"], posMenuButton, Color.White);
            //Inventar Button
            Vector2 posInventarButton = new Vector2(ScreenSizeHelper.SizeWidth - MainGame.Textures["Overlay/InventarButton"].Width, ScreenSizeHelper.SizeHeight - MainGame.Textures["Overlay/InventarButton"].Height);
            spriteBatch.Draw(MainGame.Textures["Overlay/InventarButton"], posInventarButton, Color.White);
            //HotKeyBar (Left)
            Vector2 posHKBLeft = new Vector2(posMenuButton.X + MainGame.Textures["Overlay/MenuButton"].Width - 7, ScreenSizeHelper.SizeHeight - MainGame.Textures["Overlay/HotKeyBarLeft"].Height);
            spriteBatch.Draw(MainGame.Textures["Overlay/HotKeyBarLeft"], posHKBLeft, Color.White);
            //HotKeyBar (Right)
            Vector2 posHKBRight = new Vector2(posInventarButton.X - MainGame.Textures["Overlay/HotKeyBarRight"].Width + 7, ScreenSizeHelper.SizeHeight - MainGame.Textures["Overlay/HotKeyBarRight"].Height);
            spriteBatch.Draw(MainGame.Textures["Overlay/HotKeyBarRight"], posHKBRight, Color.White);
            //HotKeyBar (Middle)
            Rectangle posHKBMiddle = new Rectangle((int)posHKBLeft.X + MainGame.Textures["Overlay/HotKeyBarLeft"].Width, (int)posHKBLeft.Y, 0, MainGame.Textures["Overlay/HotKeyBarMiddle"].Height);
            posHKBMiddle.Width = (int)posHKBRight.X - (int)posHKBMiddle.X;
            spriteBatch.Draw(MainGame.Textures["Overlay/HotKeyBarMiddle"], posHKBMiddle, Color.White);
            //HotKeys
            spriteBatch.Draw(MainGame.Textures["Overlay/HotKeys"], new Vector2(posHKBMiddle.X - 44, posHKBMiddle.Y), Color.White);
            //Lebensleiste
            Vector2 fullTP = new Vector2(posHKBLeft.X, posHKBLeft.Y - MainGame.Textures["Overlay/Lebensleiste"].Height);
            int x = 0;
            for (x = 0; x < (int)((ScreenSizeHelper.SizeWidth / 2 - 78) / MainGame.Textures["Overlay/Lebensleiste"].Width); x++)
            {
                spriteBatch.Draw(MainGame.Textures["Overlay/Lebensleiste"], fullTP + new Vector2(x * MainGame.Textures["Overlay/Lebensleiste"].Width, 0), Color.White);
            }
            int rest = (ScreenSizeHelper.SizeWidth / 2 - 78) - (x * MainGame.Textures["Overlay/Lebensleiste"].Width);
            spriteBatch.Draw(MainGame.Textures["Overlay/Lebensleiste"], new Rectangle((int)fullTP.X + (ScreenSizeHelper.SizeWidth / 2 - 78) - rest, (int)fullTP.Y, rest, MainGame.Textures["Overlay/Lebensleiste"].Height), Color.White);
            //Ausleiste
            Vector2 fullAD = new Vector2(fullTP.X + ScreenSizeHelper.SizeWidth / 2 - 78, fullTP.Y);
            x = 0;
            for (x = 0; x < (int)((ScreenSizeHelper.SizeWidth / 2 - 78) / MainGame.Textures["Overlay/Ausdauerleiste"].Width); x++)
            {
                spriteBatch.Draw(MainGame.Textures["Overlay/Ausdauerleiste"], fullAD + new Vector2(x * MainGame.Textures["Overlay/Ausdauerleiste"].Width, 0), Color.White);
            }
            rest = (ScreenSizeHelper.SizeWidth / 2 - 78) - (x * MainGame.Textures["Overlay/Ausdauerleiste"].Width);
            spriteBatch.Draw(MainGame.Textures["Overlay/Ausdauerleiste"], new Rectangle((int)fullAD.X + (ScreenSizeHelper.SizeWidth / 2 - 78) - rest, (int)fullAD.Y, rest, MainGame.Textures["Overlay/Ausdauerleiste"].Height), Color.White);
        }

        public void Update(GameTime gameTime)
        {

        }
    }
}
